﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for clsNHATKY_HETHONG
/// </summary>
public class clsNHATKY_HETHONG
{
	public clsNHATKY_HETHONG()
	{
		//
		// TODO: Add constructor logic here
		//
    }

    #region Select
    public static DataTable Select()
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        try
        {
            dt = connect.GetSelectCommand("NHATKYHETHONG_Select",null);
        }
        catch{}
        return dt;
    }
    public static DataTable Select_By_Year(int year)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@year", year);
        try
        {
            dt = connect.GetSelectCommand("NHATKYHETHONG_Select_By_Year", para);
        }
        catch { }
        return dt;
    }
    public static DataTable Select_By_Year_Month(int year,int month)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@year", year);
        para[1] = new SqlParameter("@month", month);
        try
        {
            dt = connect.GetSelectCommand("NHATKYHETHONG_Select_By_Year_Month", para);
        }
        catch { }
        return dt;
    }
    #endregion

    #region Insert
    public static void Insert(int F_MANV, string F_CHUCNANG, string F_HANHDONG, string F_MOTA, DateTime F_THOIGIAN, string F_IP, string F_BROWSER)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[7];
        para[0] = new SqlParameter("@F_MANV", F_MANV);
        para[1] = new SqlParameter("@F_CHUCNANG", F_CHUCNANG);
        para[2] = new SqlParameter("@F_HANHDONG", F_HANHDONG);        
        para[3] = new SqlParameter("@F_MOTA", F_MOTA);
        para[4] = new SqlParameter("@F_THOIGIAN", F_THOIGIAN);
        para[5] = new SqlParameter("@F_IP", F_IP);
        para[6] = new SqlParameter("@F_BROWSER", F_BROWSER);
        try
        {
            connect.ExecuteQuery("NHATKYHETHONG_Insert", para);
        }
        catch { }
    }
    #endregion

    #region Delelte
    public static string Delete(Guid ID)
    {
        DatabaseConnect connect = new DatabaseConnect();
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@ID", ID);
        try
        {
            connect.ExecuteQuery("NHATKY_HETHONG_Delete", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion

    #region Delete All
    public static string DeleteAll()
    {
        DatabaseConnect connect = new DatabaseConnect();
        try
        {
            connect.ExecuteQuery("NHATKY_HETHONG_DeleteAll", null);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion
}